package com.lanou.beautifulwardrobe.home.adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.android.volley.toolbox.ImageLoader;
import com.lanou.beautifulwardrobe.R;
import com.lanou.beautifulwardrobe.contants.VolleySingleton;
import com.lanou.beautifulwardrobe.entify.DetailPropsName;

import java.util.List;

/**
 * Created by dllo on 15/11/3.
 */
public class ParameterListViewAdapter extends BaseAdapter {
    private List<DetailPropsName> datas;
    private VolleySingleton volleySingleton = VolleySingleton.getInstance();
    private ImageLoader imageLoader;

    public void addData(List<DetailPropsName> datas) {
        this.datas = datas;
        notifyDataSetChanged();
    }

    @Override
    public int getCount() {
        return datas != null && datas.size() > 0 ? datas.size() : 0;
    }

    @Override
    public Object getItem(int position) {
        return datas != null && datas.size() > 0 ? datas.get(position) : null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ParameterViewHolder holder = null;
        if (convertView == null) {
            convertView = LayoutInflater.from(parent.getContext()).inflate(R.layout.home_product_parameter_item, null);
            holder = new ParameterViewHolder();


            holder.parapname= (TextView) convertView.findViewById(R.id.parapname);
            holder.paravname= (TextView) convertView.findViewById(R.id.paravname);

            convertView.setTag(holder);
        } else {
            holder = (ParameterViewHolder) convertView.getTag();
        }
        if(datas != null && datas.size() >0 ){
            DetailPropsName propsName=datas.get(position);
            holder.parapname.setText(propsName.getPname());
            holder.paravname.setText(propsName.getVname());
        }
        return convertView;
    }

    class ParameterViewHolder {
        private TextView parapname,paravname;

    }

}